package ru.cod.rs.main.units;

import ru.cod.rs.main.enums.Direction;
import ru.cod.rs.main.enums.Side;
import ru.cod.rs.main.types.LevelPreferences;
import ru.cod.rs.main.types.Speed;

@Deprecated
public abstract class MoveUnit extends SideUnit {

	protected Speed speed;
	protected int xDestination;

	public MoveUnit(LevelPreferences cntx, Side s) {
		super(cntx, s);

		speed = new Speed(2, Direction.RIGHT);
		xDestination = cntx.getRightEnd() - getWidth();

		if (s.equals(Side.ENEMY)) {
			xDestination = 0;
			speed.setDirection(Direction.LEFT);
		}
	}

	// /////////////////////////////////////////////////
	/*
	 * @see ru.cod.rs.main.units.AbstractUnit#update()
	 */
	@Override
	public void update() {
		if ((Math.abs(x - xDestination) >= speed.getValue())
				&& (x != xDestination)) {
			x += speed.getValue();
		}
	}
	// /////////////////////////////////////////////////

}
